Environment-variables
Environment Variables:
- in Linux there is 2 types of Variables:
-
shellvariables = denoted by lower-case$shell.
-
Enviromentvariables denoted by upper-case$SHELL
- these Variables are built in our system or added after installing Tools or application
what Environment Variable do ?
- it store
key=valuepair that control process and Interfaces(genome/Wayland) in linux system. - Example:
SHELL=/bin/zsh - Also it can contain multiple values like key=
val1:val2:val3.
Viewing Default Environment Variables:
env
printenv
View all Variables
- we can view all
shellandEnvironmentvariables.
set | less
- Utilize
grepto FILTER for particular variable.
set | grep HISTSIZE
Changing Variable Value on a Terminal session:
- this varaible will not availiable globally only limited to that terminal session.
- if u close the terminal the saved Enviroment variable will reset to the Oraginal Value
- or the Stored Variable will be
LostafterClosingtheTerminal.
Example:
EXAMPLE=8.8.8.8
Example of Changing Environment Variable:
- Changing the Shell Prompt.
PS1is an environment variable in Linux that defines the primary prompt string displayed in the terminal, allowing customization of the command prompt appearance.
PS1='C:\w >'
# \w = directoey
# \u = user
# \h = hostname
Creating global variable to use in multiple session
- creating the varaible that can be called in multiple terminal sessions.
IP=1.1.1.1
export IP
SCREENSHOST MULTIPLE SESSIONS
- Set up the
Variableto exported
- Checking if the the Variable can be called in other terminal sessions Note: I am using
tmux.
- Example use Case of Variable.